window.addEventListener( 'load',function(){

    // 用户名长度验证
    let userName=getEle( '#username' );
    let pwd=getEle( '#pwd' );
    let err=userName.nextElementSibling;
    let wrong=pwd.nextElementSibling;   

    userName.addEventListener( 'blur',function(){
        let len1=userName.value.length;
       if(!(len1>=6&&len1<=20)){
        err.textContent=err.getAttribute( 'err' )
       } 
    } )
    
    // 密码长度验证
    pwd.addEventListener( 'blur',function(){
        let len2=pwd.value.length;
       if(!(len2>=6&&len2<12)){
        wrong.textContent=wrong.getAttribute( 'wrong' )
       } 
    } )

    // 表单注册验证
    let form=getEle( 'form' )
    form.addEventListener( 'submit',function(e){
        let len1=userName.value.length;
        let len2=pwd.value.length;
        if(!((len1>=6&&len1<=20)&&(len2>=6&&len2<12))){
            e.preventDefault();
        }
    } )






} )